#include #include #include #include using namespace std; #define MAXPATIENTS 100 // define structure for patient data struct patient { char FirstName[50]; char LastName[50]; char ID[20]; char dep[50]; }; class queue { public: queue (void); int AddPatientAtEnd (patient p); int AddPatientAtBeginning (patient p); patient GetNextPatient (void); void OutputList (void); char DepartmentName[50]; private: int NumberOfPatients; patient List[MAXPATIENTS]; }; queue::queue () { NumberOfPatients = 0; } int queue::AddPatientAtEnd (patient p) { if (NumberOfPatients >= MAXPATIENTS) { return 0; } else List[NumberOfPatients] = p; NumberOfPatients++; return 1; } int queue::AddPatientAtBeginning (patient p) { int i; if (NumberOfPatients >= MAXPATIENTS) { return 0; } for (i = NumberOfPatients-1; i >= 0; i--) { List[i+1] = List[i]; } List[0] = p; NumberOfPatients++; return 1; } patient queue::GetNextPatient (void) { int i; patient p; if (NumberOfPatients == 0) { strcpy(p.ID,""); return p;} p = List[0]; NumberOfPatients--; for (i=0; iID[0]==0) { cout << "No patient"; return; } else cout << "Patient data:\n"; cout << "Your patient name is:" << p->FirstName<<" "<< p->LastName; cout << " His/Her ID is: " << p->ID; cout<<" His/Her Departement is: "<dep; } int ReadNumber() { char buffer[20]; cin.getline(buffer, sizeof(buffer)); return atoi(buffer); } using namespace std; int DepartmentMenu (queue * q) { int choice = 0, success; patient p; while (choice != 6) { cout << "Welcome to department:\n" << q->DepartmentName<AddPatientAtEnd(p) ; if (success) { cout << "Patient added:"; } else { cout << "Error: The queue is full. Cannot add patient:"; } OutputPatient(&p); cout << "Press any key"; getch(); } break; case 2: p = InputPatient(); if (p.ID[0]) { success = q->AddPatientAtBeginning(p); if (success) { cout << "Patient added:"; } else { cout << "Error: The queue is full. Cannot add patient:"; } OutputPatient(&p); cout << "Press any key"; getch(); } break; case 3: p = q->GetNextPatient(); if (p.ID[0]) { cout << "Patient to refer:"; OutputPatient(&p);} else { cout << "There is no patient to refer."; } cout << "Press any key"; getch(); break; case 4: q->OutputList(); cout << "Press any key"; getch(); break; } } return 0; } int main () { int i, MenuChoice = 0; queue departments[3]; strcpy (departments[0].DepartmentName, "NORMAL CASE"); strcpy (departments[1].DepartmentName, "EMERGENCY CASE"); strcpy (departments[2].DepartmentName, "OTHER SPECIAL CASE"); while (MenuChoice != 4) { cout<<"[]========================================================[]\n"; cout<<"[] WELCOME TO AMU CLINIC MANAGEMENT INFORMATION []\n"; cout<<"[] SYSTEM [] \n"; cout<<"[]========================================================[]\n\n"; cout<<" DEVELOPED BY ID \n"; cout<<"1.Gadisa Regassa .......................1663/10"<= 1 && MenuChoice <= 3) { DepartmentMenu (departments + (MenuChoice-1)); } } return 0; }